package com.longge;

public class ThousandSeparator {

    public String thousandSeparator(int n) {
        char[] chars = String.valueOf(n).toCharArray();
        StringBuilder sb = new StringBuilder();
        int i = 0;
        for (int j = chars.length - 1; j >= 0; j--) {
            char aChar = chars[j];
            sb.append(aChar);
            i++;
            if (i == 3 && j != 0) {
                sb.append('.');
                i = 0;
            }
        }
        return sb.reverse().toString();
    }
}
